/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * 
 * Copyright 2012 Medavie BlueCross. All rights reserved.
 * 
 * The contents of this file are subject to the Medavie Blue Cross
 * Application Code terms of use policy, for more information contact
 * Medavie Blue Cross.
 */
package com.binkam.merashehar.dao;

import com.binkam.merashehar.common.database.MSHibernateUtil;
import com.binkam.merashehar.dto.Category;
import com.binkam.merashehar.dto.Categorytype;
import com.binkam.merashehar.dto.Subcategory;
import java.util.Iterator;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author sunchak
 */
public class CategoryDAO {

    public void addCategory(Category category) {
        MSHibernateUtil.getSessionFactory().openSession().save(category);
    //MSHibernateUtil.getSessionFactory().getCurrentSession().flush();
    //MSHibernateUtil.getSessionFactory().getCurrentSession().close();
    }

    public List findCategories() {
        String sql = "from Category ";
        Session session = MSHibernateUtil.getSessionFactory().openSession();
        Query query = session.createQuery(sql);
        List catList = query.list();
        return catList;
    }

    public static void main(String[] args) {
        
        CategoryDAO categoryDAO = new CategoryDAO();
        categoryDAO.findCategories();
    }
}
